#ifndef MIN_HEAP
#define MIN_HEAP

#include <iostream>
#include <netinet/in.h>
#include <time.h>
using std::exception;

#define BUFFER_SIZE 64

class heap_timer;
/*绑定socket和定时器*/
struct client_data
{
    sockaddr_in address;
    int sockfd;
    char buf[BUFFER_SIZE];
    heap_timer* timer;
};

/*定时器类*/
class heap_timer
{
public:
    heap_timer(int delay)
    {
        expire = time(NULL) + delay;
    }
public:
    time_t expire; /*定时器生效的绝对时间*/
    void(*cb_func)(client_data*); /*定时器回调函数*/
    client_data* user_data; /*用户数据*/
}

/*时间堆类*/
class timer_heap
{
public:
    /*构造函数 1 ，初始化一个大小为cap的空堆*/
    time_heap(int cap) throw (std::exception) : capacity(cap), cur_size(0)
    {
        array = new heap_timer*[capacity]
    }
private:
    heap_timer** array; /*堆数组*/
    int capacity; /*堆数组的容量*/
    int cur_size; /*堆数组当前包含元素的个数*/
};
#endif